//
//  HeadView.m
//  MilkProject
//
//  Created by 叶子韬韬 on 2017/3/8.
//  Copyright © 2017年 叶子韬韬. All rights reserved.
//

#import "HeadView.h"

@implementation HeadView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor clearColor];
        
        [self addSubview:self.iconBtn];
        [self addSubview:self.userNameLabel];
        [self addSubview:self.allOrderBtn];
        [self addSubview:self.WaitOrderBtn];
        [self addSubview:self.FinishOrderBtn];
        [self addSubview:self.settingBtn];
        [self addSubview:self.allOrderLabel];
        [self addSubview:self.WaitOrderLabel];
        [self addSubview:self.FinishOrderLabel];
        
    }
    return self;
}
-(UIButton *)iconBtn {
    if (!_iconBtn) {
        _iconBtn = [[UIButton alloc]init];
        _iconBtn.clipsToBounds = YES;
        _iconBtn.layer.cornerRadius = 40;
        _iconBtn.layer.borderColor = [UIColor whiteColor].CGColor;
        _iconBtn.layer.borderWidth = 1;
        _iconBtn.tag = 20;
        [_iconBtn setImage:[UIImage imageNamed:@"25.jpg"] forState:UIControlStateNormal];
        [_iconBtn addTarget:self action:@selector(touch:) forControlEvents:UIControlEventTouchUpInside];
        _iconBtn.frame = CGRectMake(KSCREENWIDTH/2-40, 30, 80, 80);
    }
    return _iconBtn;
}
-(UILabel *)userNameLabel{
    if (!_userNameLabel) {
        _userNameLabel = [[UILabel alloc]init];
        _userNameLabel.textAlignment = NSTextAlignmentCenter;
        _userNameLabel.frame = CGRectMake(KSCREENWIDTH/2-100, 120, 200, 30);
        _userNameLabel.text = @"下午五点";
    }
    return _userNameLabel;
}
-(UIButton *)settingBtn{
    if (!_settingBtn) {
        _settingBtn = [[UIButton alloc]init];
        [_settingBtn setImage:[UIImage imageNamed:@"me_setting@3x.png"] forState:UIControlStateNormal];
        _settingBtn.tag = 21;
        [_settingBtn addTarget:self action:@selector(touch:) forControlEvents:UIControlEventTouchUpInside];
        _settingBtn.frame = CGRectMake(KSCREENWIDTH-40, 20, 30, 30);
    }
    return _settingBtn;
}
-(UIButton *)allOrderBtn{
    if (!_allOrderBtn) {
        _allOrderBtn = [[UIButton alloc]init];
        [_allOrderBtn setImage:[UIImage imageNamed:@"AllOrder@3x.png"] forState:UIControlStateNormal];
        _allOrderBtn.tag = 22;
        [_allOrderBtn addTarget:self action:@selector(touch:) forControlEvents:UIControlEventTouchUpInside];
        _allOrderBtn.frame = CGRectMake(0, 160, KSCREENWIDTH/3, 40);
    }
    return _allOrderBtn;
}
-(UILabel *)allOrderLabel{
    if (!_allOrderLabel) {
        _allOrderLabel = [[UILabel alloc]init];
        _allOrderLabel.textAlignment = NSTextAlignmentCenter;
        _allOrderLabel.text = @"全部订单";
        _allOrderLabel.frame = CGRectMake(0, 200, KSCREENWIDTH/3, 30);
    }
    return _allOrderLabel;
}
-(UIButton *)WaitOrderBtn{
    if (!_WaitOrderBtn) {
        _WaitOrderBtn = [[UIButton alloc]init];
        [_WaitOrderBtn setImage:[UIImage imageNamed:@"WaitOrder@3x.png"] forState:UIControlStateNormal];
        _WaitOrderBtn.tag = 23;
        [_WaitOrderBtn addTarget:self action:@selector(touch:) forControlEvents:UIControlEventTouchUpInside];
        _WaitOrderBtn.frame = CGRectMake(KSCREENWIDTH/3, 160, KSCREENWIDTH/3, 40);
    }
    return _WaitOrderBtn;
}
-(UILabel *)WaitOrderLabel{
    if (!_WaitOrderLabel) {
        _WaitOrderLabel = [[UILabel alloc]init];
        _WaitOrderLabel.textAlignment = NSTextAlignmentCenter;
        _WaitOrderLabel.text = @"待付款";
        _WaitOrderLabel.frame = CGRectMake(KSCREENWIDTH/3, 200, KSCREENWIDTH/3, 40);
    }
    return _WaitOrderLabel;
}

-(UIButton *)FinishOrderBtn{
    if (!_FinishOrderBtn) {
        _FinishOrderBtn = [[UIButton alloc]init];
        [_FinishOrderBtn setImage:[UIImage imageNamed:@"FinishOrder@3x.png"] forState:UIControlStateNormal];
        _FinishOrderBtn.tag = 24;
        [_FinishOrderBtn addTarget:self action:@selector(touch:) forControlEvents:UIControlEventTouchUpInside];
        _FinishOrderBtn.frame = CGRectMake(KSCREENWIDTH/3*2, 160, KSCREENWIDTH/3, 40);
    }
    return _FinishOrderBtn;
}
-(UILabel *)FinishOrderLabel{
    if (!_FinishOrderLabel) {
        _FinishOrderLabel = [[UILabel alloc]init];
        _FinishOrderLabel.textAlignment = NSTextAlignmentCenter;
        _FinishOrderLabel.text = @"已完成";
        _FinishOrderLabel.frame = CGRectMake(KSCREENWIDTH/3*2, 200, KSCREENWIDTH/3, 40);
    }
    return _FinishOrderLabel;
}
-(void)touch:(UIButton *)sender{
    
    self.action(sender.tag);
}
@end
